package main.gui.dataobjecteditor;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class DataObjectEditor extends JPanel {

	private static final long serialVersionUID = 5487543706140268795L;

	public static final Font ATTRIBUTE_FONT = new Font("Calibri", Font.BOLD, 16);
	public static final Font HEADER_FONT = new Font("Calibri", Font.BOLD, 18);

	private boolean colorFlag;

	public DataObjectEditor(int numAttributes, int numSections) {
		super();
		GridLayout layout = new GridLayout(numAttributes + numSections, 2);
		this.setLayout(layout);

		this.colorFlag = true;
	}

	public void addSectionHeader(String title) {
		this.setBackground(new Color(62, 142, 134));
		JLabel headerLabel = new JLabel(title, JLabel.CENTER);
		headerLabel.setFont(HEADER_FONT);
		this.add(headerLabel);
		this.add(new JLabel());
	}

	public void addAttributePanel(DataAttributePanel panel,
			String attrDisplayName, String helpText, Object value) {
		AttributeNamePanel attrNamePanel = new AttributeNamePanel(
				attrDisplayName, helpText);
		if (colorFlag) {
			panel.setBackground(new Color(180, 180, 180));
			attrNamePanel.setBackground(new Color(180, 180, 180));
		} else {
			panel.setBackground(new Color(200, 200, 200));
			attrNamePanel.setBackground(new Color(200, 200, 200));
		}
		colorFlag = !colorFlag;
		panel.buildPanel(value);
		this.add(attrNamePanel);
		this.add(panel);
	}
}
